
#include "stdafx.h"
#include "../client/DCPlusPlus.h"
#include "Resource.h"
#include "WinUtil.h"

#include "FileListDetectorDlg.h"

#define GET_TEXT(id, var) \
	GetDlgItemText(id, buf, 1024); \
	var = buf;

#define ATTACH(id, var) var.Attach(GetDlgItem(id))

LRESULT FileListDetectorDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	if(currentProfileId != -1) {
		adding = false;
		getProfile();
	} else {
		adding = true;
	}

	getProfile();

	ATTACH(IDC_FILELIST_PROFILE_NAME, ctrlName);
	ATTACH(IDC_FILELIST_PROFILE_CHEAT, ctrlCheatingDescription);
	//Sulan start svn120
	ATTACH(IDC_FILELIST_PROFILE_CLIENT, ctrlClient);
	//End

	ATTACH(IDC_FILELIST_PROFILE_RAW, ctrlRaw);
	//Sulan start svn209
	for(int n=0;n<11;){
		ctrlRaw.AddString(RAWSETTING(n).c_str());
		++n;
	}
	//End
	updateControls();
	
	CenterWindow(GetParent());
	return FALSE;
}

void FileListDetectorDlg::getProfile() {
	ClientProfileManager::getInstance()->getFileListDetector(currentProfileId, currentProfile);

	name = currentProfile.getName();
	cheatingDescription = currentProfile.getCheatingDescription();
	rawToSend = currentProfile.getRawToSend();
	//Sulan start svn120
	client = currentProfile.getClient();
	//End
}

void FileListDetectorDlg::updateControls() {
	
	ctrlName.SetWindowText(name.c_str());
	ctrlCheatingDescription.SetWindowText(cheatingDescription.c_str());
	ctrlRaw.SetCurSel(rawToSend);
	//Sulan start svn120
	ctrlClient.SetWindowText(client.c_str());
	//End
	ctrlName.SetFocus();
}
void FileListDetectorDlg::updateVars() {
	TCHAR buf[1024];

	GET_TEXT(IDC_FILELIST_PROFILE_NAME, name);
	GET_TEXT(IDC_FILELIST_PROFILE_CHEAT, cheatingDescription);
	//Sulan start svn120
	GET_TEXT(IDC_FILELIST_PROFILE_CLIENT, client);
	//END
	rawToSend = ctrlRaw.GetCurSel();
}